package com.learn.springboot.controller.database.redis;

import com.learn.springboot.entity.pojo.UmsAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangxing
 * @version 2020/8/4 14:29 Administrator
 */
@RestController
@RequestMapping("/serialize")
public class SerializeController {
    @Autowired
    private RedisTemplate redisTemplate;
    @PutMapping("/setUmsAdmin")
    public String setUmsAdmin(UmsAdmin umsAdmin){
        redisTemplate.opsForValue().set("umsAdmin", umsAdmin);
        return "success";
    }
    @GetMapping("/setUmsAdmin")
    public UmsAdmin getUmsAdmin(){
        return (UmsAdmin)redisTemplate.opsForValue().get("umsAdmin");
    }
}
